package MapReduce.yasuo;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class WordCountReducer extends Reducer<Text, IntWritable, Text, IntWritable> {
    IntWritable result = new IntWritable();

    public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException,InterruptedException {
        int ans = 0;
        for(IntWritable val : values) {
            ans += val.get();
        }
        result.set(ans);
        //格式：<String word ,int num>
        context.write(key,result);
    }
}